<template>
  <div id="App">
    <header class="site-header jumbotron">
      <div class="container">
        <div class="row">
          <div class="col-xs-12">
            <h1>请发表对vue的评论</h1>
          </div>
        </div>
      </div>
    </header>
    <div class="container">
      <Add @addCom="addComment" /><!--向子组件Add传递函数-->
      <List :comments="comments" :delItem="delItem"/> <!--向子组件List传递数据-->
    </div>
  </div>
</template>

<script>
import Add from './components/Add'
import List from './components/List'
import Item from './components/Item'

export default {
  data () {
    return {
      comments: [
        {name: 'leo', age: 22},
        {name: 'leo', age: 22}
      ]
    }
  },
  methods: {
    addComment (comment) {
      this.comments.unshift(comment)
    },
    delItem (comment) {
      alert('delete' + JSON.stringify(comment))
    }
  },
  components: {
    Add, List, Item
  }
}
</script>

<style>
</style>
